<template>
    <div class="syntheticalInput">
        <div class="title">综合处理列表</div>
        <div class="syntheticalInput-content">
            <hr v-show="role == 0" class="syntheticalInput-hr">
            <label class="filterText">关键字</label>
            <el-input class="syntheticalInput-input-filter" placeholder="请输入姓名/身份证号/订单号" v-model="filter.text" icon="circle-cross" :on-icon-click="deleFilterText">
            </el-input>
            <label class="filterText">业务员</label>
            <el-input class="order-input-short" placeholder="请输入姓名" v-model="filter.salemanName"></el-input>
            <!-- <label class="filterText">业务部门</label> -->
            <!-- <el-autocomplete class="creditList-input-selemanName inline-input" v-model="filter.saleDep" placeholder="请输入业务部门"></el-autocomplete> -->
            <label class="filterText">申请日期</label>
            <el-date-picker v-model="filter.time" type="daterange" placeholder="选择日期">
            </el-date-picker>
            <el-button class="filter-button-search" type="primary" icon="search" @click="search">搜索</el-button>
            <el-table class="syntheticalInput-table" :data="tableData" style="width: 100%" empty-text="暂无搜索结果" @filter-change="filterChange">
                <el-table-column prop="orderNo" label="订单编号" width="130">
                </el-table-column>
                <el-table-column prop="name" label="姓名" width="100">
                </el-table-column>
                <el-table-column prop="code" label="身份证号" width="200">
                </el-table-column>
                <el-table-column prop="carModel" label="车型" width="100">
                </el-table-column>
                <el-table-column prop="deptName" label="业务部门" width="120">
                </el-table-column>
                <el-table-column prop="staffName" label="业务员" width="120">
                </el-table-column>
                <el-table-column prop="bank" label="贷款银行" :filters="$store.state.bank" filter-placement="bottom-end" width="120">
                </el-table-column>
                <el-table-column prop="money" label="贷款金额" width="100">
                </el-table-column>
                <el-table-column prop="time" label="申请时间" sortable width="180">
                </el-table-column>
                <el-table-column fixed="right" label="操作" width="80">
                    <template scope="scope">
                        <el-button type="text" size="small">
                            <router-link :to="{path:'/synInput?orderNo='+scope.row.orderNo+'&annexBatchNo='+scope.row.annexBatchNo+'&customerIdCard='+scope.row.code}">录入</router-link>
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="syntheticalInput-pagination">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="tablePage.page" :page-sizes="[10, 20, 30, 40]" :page-size="tablePage.num" layout="sizes, prev, pager, next" :total="tablePage.pager">
                </el-pagination>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    name: 'syntheticalInput',
    components: {},
    data() {
        return {
            role: 1, //0-业务员 1-业务经理
            filter: {
                time: [],
                text: '',
                bank: '',
                bankList: [],
                status: '',
                salemanName: '', //业务员名称
                salemanNameList: [
                    { value: '名称1' },
                    { value: '名称2' }
                ],
            },
            tableData: [],
            tablePage: {
                pager: 1, //总页数
                page: 1, //当前页数
                num: 10, //每页条数
            },
        }
    },
    methods: {
        getSalemanNameList(queryString, cb) {
            cb(this.filter.salemanNameList);
        },
        filterChange(data) {
            for (let i in data) {
                switch (i) {
                    case 'status':
                        this.filter.status = data[i][data[i].length - 1];
                        this.filter.statusList = data[i];
                        break;
                    case 'bank':
                        this.filter.bank = data[i][data[i].length - 1];
                        this.filter.bankList = data[i];
                        break;
                }
            }
            this.search();
        },
        info(index, rows) {
            console.log(rows);
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.tablePage.num = val;
            this.search();
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.tablePage.page = val;
            this.search();
        },
        deleFilterText() {
            this.filter.text = '';
        },
        search() {
            console.log(this.filter.salemanName);
            let param = {
                gmtCreateBegin: this.filter.time[0] ? this.$libs.formatDate(this.filter.time[0]) : '',
                gmtCreateEnd: this.filter.time[1] ? this.$libs.formatDate(this.filter.time[1]) : '',
                keyword: this.filter.text,
                loanBankId: this.filter.bankList.length > 1 ? '' : this.filter.bank,
                loanBankIdList: this.filter.bankList.length > 1 ? this.filter.bankList.join('%2C') : '',
                orderStatusList: this.$store.state.power == 'ROLE_COOPERATIVE' ? (22 + '%2C' + 31 + '%2C' + 32 + '%2C' + 41 + '%2C' + 51) : '',
                pageNO: this.tablePage.page,
                pageSize: this.tablePage.num,
                staffName: this.filter.salemanName
            };

            this.tableData = [];
            this.$http.get(this.$libs.getUrlSplit("/order/orders", param)).then((response) => {
                console.log(response);
                if (response.data.success) {
                    console.log(response.data.result);
                    let that = this;
                    that.tablePage.pager = parseInt(response.data.totalPage) + 1;
                    that.tablePage.num = parseInt(response.data.pageSize) + 1;
                    console.log(that.tablePage);
                    $.each(response.data.data.result, function(index, el) {
                        that.tableData.push({
                            orderNo: el.orderNo,
                            name: el.customerName,
                            code: el.customerIdCard,
                            carModel: el.carModel,
                            deptName: el.deptName,
                            staffName: el.staffName,
                            bank: el.loanBankName,
                            money: el.loanAmount,
                            time: el.gmtCreate,
                            annexBatchNo: el.annexBatchNo
                        })
                    });
                }
            }).catch((error) => {});

        },
    },
    mounted() {
        this.search();
        this.$store.commit('bank', this);
    }
}

</script>
<style lang="scss" scoped>
.syntheticalInput {
    padding: 10px 16px;

    .title {
        color: #99A9BF;
        font-size: 14px;
        line-height: 18px;
        margin: 8px 0px 10px 0px;
    }
    .syntheticalInput-content {
        background: #fff;
        position: fixed;
        top: 96px;
        bottom: 10px;
        left: 216px;
        right: 16px;
        overflow: auto;
        padding: 20px;
        .filterText {
            font-size: 14px;
            color: #475669;
            margin: 0px 5px 0px 15px;
        }
        .syntheticalInput-hr {
            margin: 20px 0px 30px 0px;
            background: #D3DCE6;
        }
        .syntheticalInput-input-selemanName {
            width: 190px;
            margin-bottom: 10px;
            .syntheticalInput-input-name {
                width: 90px;
            }
        }
        .syntheticalInput-input-filter {
            width: 285px;
        }
        .filter-button-search {
            margin-left: 30px;
        }
        .syntheticalInput-table {
            margin: 20px 0px;
        }
        .syntheticalInput-pagination {
            text-align: center;
        }
        .order-input-short {
            width: 100px;
        }
        a {
            color: #20a0ff;
        }
    }
}

</style>
